#include <iostream>
using namespace std;
#include <cstring>
#include <list>
#include <cstdio>

int main() {
	char str[21];
	gets(str);
	int len = strlen(str);
	list<char>l;
	char c;
	int pos;
	for (int i = 0; i < len; i++) {
		l.push_back(str[i]);
	}
	/*
	auto it = l.begin();
	while (it != l.end()) {
		printf("%c", *it);
		it++;
	}
	it = l.begin();
	*/
	while (len != 0) {
		char temp;
		int sum1 = 0;
		int sum2 = 0;
		scanf("%c %d", &c, &pos);
		getchar();
		auto it = l.begin();
		for (int i = 0; i < pos - 1; i++) {
			it++;
		}
		l.insert(it, c);
		len++;

		auto it1 = it;
		while (it1!= l.begin()) {
			if (*it1 == c) {
				sum1++;
			} else {
				break;
			}
			it1--;
		}
		it1 = it;
		while ((++it1) != l.end()) {
			if (*it1 == c) {
				sum2++;
			} else {
				break;
			}
		}
		it1 = it;
		if (sum1 + sum2 + 1 >= 3) {
			it1++;
			for (int i = 0; i < sum2; i++) {
				l.erase(it1);
				it1++;
			}
			it1 = it;
			for (int i = 0; i < sum1; i++) {
				it1--;
			}
			for (int i = 0; i < sum1; i++) {
				l.erase(it1);
			}

			it1 = it;
			len -= sum1 + sum2 + 1;
			//printf("%d\n", len);
			l.erase(it);
			if (len == 0) {
				printf("You win!");
				return 0;
			}
		}
		it = l.begin();
		while (it != l.end()) {
			printf("%c", *it);
			it++;
		}

		printf("\n");

	}

}